<?php

namespace app\console\model;

use think\Model;
use think\Request;
use app\console\model\ShopHelp as ShopHelpModel;

class ShopHelpInformation extends Model
{
    // 栏目名称
    protected function getParenTextAttr($value, $data)
    {
        $parenText = (new ShopHelpModel)->where('id', $data['parenTid'])->value('title');

        return $parenText;
    }

    // 模型事件
    protected static function init()
    {
        // 写入前
        self::event('before_write', function ($data) {
            $data->picUrl = uploadImg('picUrl', 'shop');
            $data->update_time = time();
            $data->create_time = strtotime(Request::instance()->param('create_time'));
        });

    }
}
